//
//  SEGPropertyAppraisalCollectionReusableView.m
//  SEGUhomePropertyBaseService
//
//  Created by Clavis on 2018/12/10.
//  Copyright © 2018 刘山. All rights reserved.
//

#import "SEGPropertyAppraisalCollectionReusableView.h"

@interface SEGPropertyAppraisalCollectionReusableView ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *moreButton;
@end

@implementation SEGPropertyAppraisalCollectionReusableView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.titleLabel = ({
        UILabel *lable = [[UILabel alloc] init];
        [self addSubview:lable];
        lable.textColor = kColor_1;
        lable.font = [UIFont boldSystemFontOfSize:15];
        lable;
    });
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(-30);
        make.bottom.mas_equalTo(-13);
    }];
    
    self.moreButton = ({
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"更多" forState:UIControlStateNormal];
        [button setTitleColor:kColor_3 forState:UIControlStateNormal];
        button.titleLabel.font = kFont_11;
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        button.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
        button.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 13, 0);
        [button addTarget:self action:@selector(moreButtonTap) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
        button;
    });
    
    [self.moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.right.mas_equalTo(0);
    }];
}

- (void)moreButtonTap {
    if (self.clickMoreBlock) {
        self.clickMoreBlock();
    }
}

- (void)updateUIWithTitle:(NSString *)title showMoreButton:(BOOL)showMoreButton {
    self.titleLabel.text = title;
    self.moreButton.hidden = !showMoreButton;
}

@end
